package com.projectx.action.chat.GroupAnnocement;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.projectx.R;
import com.projectx.util.ActivityManage;

import java.util.List;

public class GroupdialogAdapter extends RecyclerView.Adapter<GroupdialogAdapter.VH> {

    private Context context;
    private List<String> announcement;
    private  List<Bitmap>bitmaps;
    private List<String> time;
    public GroupdialogAdapter(Context context, List<String> announcement, List<Bitmap>bitmaps,List<String> time) {
        this.context = context;
        this.announcement = announcement;
        this.bitmaps=bitmaps;
        this.time=time;
    }

    @NonNull
    @Override
    public GroupdialogAdapter.VH onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.item_announcement, parent, false);
        return new GroupdialogAdapter.VH(view);
    }

    @Override
    public void onBindViewHolder(@NonNull GroupdialogAdapter.VH holder, final int position) {
        holder.textView_content.setText(announcement.get(position));
       // holder.imageView.setImageBitmap(bitmaps.get(position));
        holder.textView_time.setText(time.get(position));
        holder.textView_content.setLines(3);
        holder.view.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent(context, AnnouncementActivity.class);
                intent.putExtra("content",announcement.get(position));
                v.getContext().startActivity(intent);
            }
        });
    }

    @Override
    public int getItemCount() {
        return announcement.size();
    }

    public static class VH extends RecyclerView.ViewHolder {

        TextView textView_content;
        TextView textView_time;
        ImageView imageView;
        View view;
        public VH(@NonNull View itemView) {
            super(itemView);
            textView_content = itemView.findViewById(R.id.text);
            imageView= itemView.findViewById(R.id.imageView);
            view=itemView.findViewById(R.id.click);
            textView_time=itemView.findViewById(R.id.time);
        }
    }
}